const koa = require('koa');
const session = require('koa-session');

let server = new koa();
server.listen(8080);

server.keys = [
    'dsadijn21q90u12dhoisa',
    'dhs98iahd78Y*&SGH*dgh28911q',
    'dswasiuyqw782!W2es2ew2(*&dsxa',
]

server.use(session({}, server));

server.use(async (ctx) => {
    if (ctx.request.url.indexOf('favicon') < 0) {
        console.log(ctx.session['count']);
        if (ctx.session['count']) {
            ctx.session['count']++;
        } else {
            ctx.session['count'] = 1;
        }
        ctx.response.body = `这是第${ctx.session.count}次来访`;
    }
})